package com.tal.jzb.config;

import com.tal.jzb.interceptor.RequestHandlerInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author xiefengsong
 * @date 2019-01-24 17:48
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    RequestHandlerInterceptor requestHandlerInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器 拦截规则，多个拦截器时 以此添加 执行顺序按添加顺序
        registry.addInterceptor(requestHandlerInterceptor)
                .addPathPatterns("/test/getCurrentTime", "/test/getCurrentDate")
                .excludePathPatterns("/test/getCurrentDate");
    }
}